#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
struct ListNode* removeElements(struct ListNode* head, int val)
{
    // if(head==NULL)
    // {
    //     return NULL;
    // }
    struct ListNode* prev = NULL;
    struct ListNode* cur = head;
    while (cur)
    {
        if (cur->val != val)
        {
            prev = cur;
            cur = cur->next;
        }
        else
        {
            if (prev == NULL)
            {
                head = cur->next;
                free(cur);
                cur = head;
            }

            else
            {
                prev->next = cur->next;
                free(cur);
                cur = NULL;
                cur = prev->next;
            }
        }

    }
    return head;
}
int main()
{
	return 0;
}